package com.unitech.drinks.exception;

import com.unitech.drinks.exception.BusinessErrorCode;
import lombok.Getter;

public class BusinessException extends RuntimeException {

    @Getter
    private final BusinessErrorCode errorCode;

    // 封装错误消息
    public BusinessException(String message) {
        super(message);
        this.errorCode = BusinessErrorCode.UNKNOWN_ERROR;
    }

    // 封装返回码和错误消息
    public BusinessException(BusinessErrorCode resultCode) {
        super(resultCode.getMessage());
        this.errorCode = resultCode;
    }

    // 封装返回码、错误消息和异常栈
    public BusinessException(BusinessErrorCode resultCode, Throwable cause) {
        super(cause);
        this.errorCode = resultCode;
    }
}
